<template>
    <div class="pt-[30px] pb-[20px] bg-white">
        <el-tabs v-model="activeStep" class="demo-tabs">
            <el-tab-pane label="基本信息" :name="0">
                <div>
                    <!-- 基本信息 -->
                    <div class="bg-white ">
                        <BaseHead>基本信息</BaseHead>
                        <div class="p-[10px]">
                            <el-descriptions title="" :column="2" border label-width="140">
                                <el-descriptions-item label-class-name="gdlable" label="标准名称">{{
            ruleForm.name
        }}</el-descriptions-item>

                                <el-descriptions-item label-class-name="gdlable" label="标准号">{{
                ruleForm.code
            }}</el-descriptions-item>
                                <el-descriptions-item label-class-name="gdlable" label="标准属性">
                                    <Feedback :id="ruleForm.propertyId" :list="bzsxList">
                                    </Feedback>
                                </el-descriptions-item>
                                <el-descriptions-item label-class-name="gdlable" label="所属单位">
                                    <Feedback :id="ruleForm.unitId" :list="zcgsdwList"
                                        :mapping="['codeColumn', 'valueColumn']">
                                    </Feedback>
                                </el-descriptions-item>
                                <el-descriptions-item label-class-name="gdlable" label="发布部门">{{
            ruleForm.publicUnit
        }}</el-descriptions-item>
                                <el-descriptions-item label-class-name="gdlable" label="提交时间">{{
                dateFormatter3(ruleForm.submitDate)
            }}</el-descriptions-item>
                                <el-descriptions-item label-class-name="gdlable" label="是否已发布">{{
                ruleForm.isPublic == 1 ? '是' : '否'
            }}</el-descriptions-item>
                                <el-descriptions-item label-class-name="gdlable" label="发布时间">{{
                dateFormatter3(ruleForm.publicDate)
            }}</el-descriptions-item>
                                <el-descriptions-item label-class-name="gdlable" label="标准类别">
                                    <Feedback :id="ruleForm.typeId" :list="bznbList">
                                    </Feedback>

                                </el-descriptions-item>
                                <el-descriptions-item label-class-name="gdlable" v-if="ruleForm.typeId == '2'"
                                    label="所属行业">
                                    <Feedback :id="ruleForm.industryId" :list="sshyList" :mapping="['id', 'label']">
                                    </Feedback>
                                </el-descriptions-item>
                                <el-descriptions-item label-class-name="gdlable" label="标准电子版">
                                    <div v-for="item in ruleForm.fileList" :key="item.id">{{ item.fileName
                                        }}<el-link type="primary" style="margin-left: 8px;"
                                            @click="downloadMet(item.id)">下载</el-link>
                                    </div>
                                </el-descriptions-item>
                                <el-descriptions-item label-class-name="gdlable" label="备注">{{
            ruleForm.note
                                    }}</el-descriptions-item>
                            </el-descriptions>
                        </div>
                    </div>
                    <!-- 制定人 -->
                    <div class="bg-white mt-[10px]">
                        <BaseHead>制定人信息</BaseHead>
                        <div class="p-[10px]">
                            <el-table :data="tableData" border style="width: 100%">
                                <el-table-column align="center" type="index" label="署名顺序" width="80" />
                                <el-table-column align="center" prop="authorType" label="制定人类型">
                                    <template #default="scope">
                                        {{
                                        scope.row.authorType == '1' ? '教师' : scope.row.authorType == '2' ? '学生'
                                        : '校外'
                                        }}</template>
                                </el-table-column>
                                <el-table-column align="center" prop="authorName" label="制定人姓名">

                                </el-table-column>
                                <el-table-column align="center" prop="eduLevelId" label="学历">
                                    <template #default="scope">
                                        <Feedback :id="scope.row.eduLevelId" :list="xlList"></Feedback>
                                    </template>
                                </el-table-column>
                                <el-table-column align="center" prop="authorUnit" label="工作单位">
                                </el-table-column>
                                <el-table-column align="center" prop="workRatio" label="贡献率（%）">
                                </el-table-column>
                            </el-table>
                        </div>
                    </div>
                </div>
            </el-tab-pane>
            <el-tab-pane label="依托项目" :name="1">
                <supportProjectView :productId="id"></supportProjectView>
            </el-tab-pane>
        </el-tabs>

    </div>
</template>
<script setup>
import BaseHead from "@/views/project/components/BaseHead.vue";
import supportProjectView from "@/views/achievement/components/supportProjectView.vue"
import useCategoryStore from "@/store/modules/category";

const props = defineProps({
    id: String,
})
const ruleForm = reactive({
});
const tableData = reactive([
]);

const categoryStore = useCategoryStore();
const { xlList, zcgsdwList, zcList, sshyList, bzsxList, bznbList } = storeToRefs(categoryStore); // 解构状态
const { getxlList, getzcgsdwList, getzcList, getsshyList, getbzsxList, getbznbList } = categoryStore; // 解构方法

const getRuleForm = (i) => {
    if (!xlList.value.length) {
        getxlList()
    }
    if (!zcgsdwList.value.length) {
        getzcgsdwList()
    }
    if (!zcList.value.length) {
        getzcList()
    }
    if (!sshyList.value.length) {
        getsshyList()
    }
    if (!bzsxList.value.length) {
        getbzsxList()
    }
    if (!bznbList.value.length) {
        getbznbList()
    }
    if (i.authorList && i.authorList.length > 0) {
        tableData.length = 0; // 清空数组
        tableData.push(...i.authorList); // 添加新元素

    }
    for (const key in i) {
        ruleForm[key] = i[key];
    }
}
const activeStep = ref(0)
const { proxy } = getCurrentInstance();
const downloadMet = (i) => {
    proxy.$download.common(i)
}

defineExpose({
    getRuleForm
})
</script>
<style lang="scss">
.gdlable {
    width: 140px;
}
</style>
<style scoped lang="scss">
@import url("@/views/achievement/index.scss");

:deep(.el-select--default) {


    .el-select__wrapper.is-disabled {
        background-color: #fff;
        box-shadow: 0 0 0 0px var(--el-select-disabled-border) inset;
        color: #606266;
        cursor: not-allowed;

        .el-select__selected-item {
            color: #606266;
        }
    }

    .el-select__suffix {
        display: none;
    }
}
</style>
